﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LaTeXGrapher
{
    public class MathHelpers
    {
        public static bool Odd(double n)
        {
            return (((int)n) & 1) != 0;
        }

        public static bool Even(double n)
        {
            return !Odd(n);
        }

        public static double OddDouble(double n)
        {
            return ToDouble(Odd(n));
        }

        public static double EvenDouble(double n)
        {
            return ToDouble(Even(n));
        }

        public static double NotDouble(double d)
        {
            return ToDouble(!ToBool(d));
        }

        public static double AndDouble(double a, double b)
        {
            return ToDouble(ToBool(a) && ToBool(b));
        }

        public static double OrDouble(double a, double b)
        {
            return ToDouble(ToBool(a) || ToBool(b));
        }

        public static double ToDouble(bool b)
        {
            return b ? 1.0 : 0.0;
        }

        public static bool ToBool(double d)
        {
            return !(d == 0.0);
        }
    }
}
